home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / DLFCN.ZIP / dlfcn / octave / ov-cx-mat.h < prev    next >
C/C++ Source or Header  |  1997-08-20  |  4KB  |  166 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_complex_matrix_h)
  24. #define octave_complex_matrix_h 1
  25.  
  26. #if defined (__GNUG__)
  27. #pragma interface
  28. #endif
  29.  
  30. #include <cstdlib>
  31.  
  32. #include <string>
  33.  
  34. class ostream;
  35.  
  36. #include "mx-base.h"
  37. #include "oct-alloc.h"
  38. #include "str-vec.h"
  39.  
  40. #include "error.h"
  41. #include "ov-base.h"
  42. #include "ov-typeinfo.h"
  43.  
  44. class Octave_map;
  45. class octave_value_list;
  46.  
  47. class tree_walker;
  48.  
  49. // Complex matrix values.
  50.  
  51. class
  52. octave_complex_matrix : public octave_base_value
  53. {
  54. public:
  55.  
  56.   octave_complex_matrix (void)
  57.     : octave_base_value () { }
  58.  
  59.   octave_complex_matrix (const ComplexMatrix& m)
  60.     : octave_base_value (), matrix (m) { }
  61.  
  62.   octave_complex_matrix (const ComplexDiagMatrix& d)
  63.     : octave_base_value (), matrix (d) { }
  64.  
  65.   octave_complex_matrix (const ComplexRowVector& v, int pcv = -1);
  66.  
  67.   octave_complex_matrix (const ComplexColumnVector& v, int pcv = -1);
  68.  
  69.   octave_complex_matrix (const octave_complex_matrix& cm)
  70.     : octave_base_value (), matrix (cm.matrix) { }
  71.  
  72.   ~octave_complex_matrix (void) { }
  73.  
  74.   octave_value *clone (void) { return new octave_complex_matrix (*this); }
  75.  
  76.   void *operator new (size_t size)
  77.     { return allocator.alloc (size); }
  78.  
  79.   void operator delete (void *p, size_t size)
  80.     { allocator.free (p, size); }
  81.  
  82.   octave_value *try_narrowing_conversion (void);
  83.  
  84.   octave_value index (const octave_value_list& idx) const;
  85.  
  86.   void assign (const octave_value_list& idx, const ComplexMatrix& rhs);
  87.  
  88.   void assign (const octave_value_list& idx, const Matrix& rhs);
  89.  
  90.   int rows (void) const { return matrix.rows (); }
  91.   int columns (void) const { return matrix.columns (); }
  92.  
  93.   bool is_defined (void) const { return true; }
  94.  
  95.   bool is_complex_matrix (void) const { return true; }
  96.  
  97.   octave_value all (void) const { return matrix.all (); }
  98.   octave_value any (void) const { return matrix.any (); }
  99.  
  100.   bool is_complex_type (void) const { return true; }
  101.  
  102.   bool is_matrix_type (void) const { return true; }
  103.  
  104.   bool is_numeric_type (void) const { return true; }
  105.  
  106.   bool valid_as_scalar_index (void) const;
  107.   bool valid_as_zero_index (void) const;
  108.  
  109.   bool is_true (void) const;
  110.  
  111.   bool is_empty (void) const { return (rows () == 0 && columns () == 0); }
  112.  
  113.   double double_value (bool) const;
  114.  
  115.   Matrix matrix_value (bool = false) const;
  116.  
  117.   Complex complex_value (bool = false) const;
  118.  
  119.   ComplexMatrix complex_matrix_value (bool = false) const;
  120.  
  121.   octave_value not (void) const { return octave_value (! matrix); }
  122.  
  123.   octave_value uminus (void) const { return octave_value (- matrix); }
  124.  
  125.   octave_value transpose (void) const
  126.     { return octave_value (matrix.transpose ()); }
  127.  
  128.   octave_value hermitian (void) const
  129.     { return octave_value (matrix.hermitian ()); }
  130.  
  131.   void increment (void) { matrix += 1.0; }
  132.  
  133.   void decrement (void) { matrix -= 1.0; }
  134.  
  135.   void print (ostream& os, bool pr_as_read_syntax = false);
  136.  
  137.   int type_id (void) const { return t_id; }
  138.  
  139.   string type_name (void) const { return t_name; }
  140.  
  141.   static int static_type_id (void) { return t_id; }
  142.  
  143.   static void register_type (void)
  144.     { t_id = octave_value_typeinfo::register_type (t_name); }
  145.  
  146. private:
  147.  
  148.   ComplexMatrix matrix;
  149.  
  150.   static octave_allocator allocator;
  151.  
  152.   // Type id of complex matrix objects, set by register_type().
  153.   static int t_id;
  154.  
  155.   // Type name of complex matrix objects, defined in ov-cx-mat.cc.
  156.   static const string t_name;
  157. };
  158.  
  159. #endif
  160.  
  161. /*
  162. ;;; Local Variables: ***
  163. ;;; mode: C++ ***
  164. ;;; End: ***
  165. */
  166.